<template>
  <div>
    <myheader></myheader>

    <section class="featured-block text-center">
      <div class="container">
        <Table :datas="search_goods" :height="400">
          <TableItem
            title="名称"
            prop="name"
            :width="150"
            align="center"
          ></TableItem>
          <TableItem
            title="商品描述"
            prop="desc"
            align="center"
            :width="150"
          ></TableItem>
          <TableItem
            title="关注数"
            prop="flow"
            :width="150"
            align="center"
          ></TableItem>
          <TableItem
            title="价格"
            prop="price"
            :width="150"
            align="center"
          ></TableItem>
          <div slot="empty">暂时无数据</div>
        </Table>
      </div>
    </section>

    <myfooter></myfooter>
  </div>
</template>


 
<script>
import myheader from "./myheader";
import myfooter from "./myfooter";
export default {
  inject: ["reload"],
  data() {
    return {
      word: "",
      search_goods: []
    };
  },
  mounted: function() {
    // 接收参数
    this.word = this.$route.query.word;
    this.get_goods();
  },
  methods: {
    // 获取商品列表
    get_goods() {
      if (this.word) {
        this.axios({
          url: "http://localhost:8000/searchgoods/",
          params: {
            inputname: this.word
          }
        }).then(res => {
          if (res.data.code == 200) {
            this.search_goods = res.data.data;
          }
        });
      }
    }
  },
  // 注册组件
  components: {
    myheader: myheader,
    myfooter: myfooter
  }
};
</script>
 
<style>
</style>